<!DOCTYPE html>
<html>
<head>
    <title>管理员列表 - 后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all">
    <script type="text/javascript" src="/static/layui/layui.js"></script>
    <style type="text/css">
        .header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
        .header div{border-bottom:solid 2px #009688;margin-top: 8px;}
        .header button{float:right;margin-top:-5px;}
    </style>
</head>
<body style="padding:10px; box-sizing: border-box;">
<form id="form" class="layui-form" enctype="multipart/form-data" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">视频名称</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="name" placeholder="请输入视频名称">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">视频上传</label>
        <div class="layui-input-inline">
            <input type="file" class="layui-input" name="video">
        </div>
    </div>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">视频地址</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" class="layui-input" name="src" placeholder="请输入视频地址">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">问题</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="question" placeholder="请输入问题">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">答案A</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="a" placeholder="请输入答案A">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">答案B</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="b" placeholder="请输入答案B">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">答案C</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="c" placeholder="请输入答案C">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">答案D</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="d" placeholder="请输入答案D">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">正确答案</label>
        <div class="layui-input-inline">
            <select name="right">
                <option value="1">A</option>
                <option value="2">B</option>
                <option value="3">C</option>
                <option value="4">D</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="开启" checked>
            <input type="radio" name="status" value="0" title="禁用">
        </div>
    </div>
</form>

<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn" onclick="save()">保存</button>
    </div>
</div>

<script type="text/javascript">
    layui.use(['form'],function(){
        form = layui.form;
        $ = layui.jquery;
    });

    function save(){
        var form = $('#form')[0];
        var formdata = new FormData(form);
        $.ajax({
            type : "POST",
            url : "/video/add",
            data : formdata,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success : function(res) {
                res = JSON.parse(res);
                if(res.code == 0){
                    layer.msg(res.message,{'icon':1});
                    //1s后关闭页面
                    setTimeout(function(){
                        parent.window.location.reload();
                    },500);
                }else{
                    layer.msg(res.message,{'icon':2});
                }
            }
        });
    }

</script>
</body>
</html>